package com.littlebee.storychild.common;

import android.app.Application;
import android.content.Context;
import android.util.Log;

import com.littlebee.storychild.common.utils.CrashHandler;

import org.xutils.BuildConfig;
import org.xutils.x;

import cn.jpush.im.android.api.JMessageClient;

/**
 * 作者：liaoyong on 2016/10/25 09:51
 * 邮箱：liaoyong@tuliu.com
 * 描述：
 */
public class BaseApplication extends Application {
    private static BaseApplication instance;

    public static BaseApplication getInstance() {
        return instance;
    }

    @Override
    public void onCreate() {
        super.onCreate();
        instance = this;

        x.Ext.init(this);
        x.Ext.setDebug(BuildConfig.DEBUG); // 是否输出debug日志, 开启debug会影响性能.

        initCrashConfig(getApplicationContext());

        Log.i("IMDebugApplication", "init");
        JMessageClient.setDebugMode(true);
        JMessageClient.init(getApplicationContext(), true);
        JMessageClient.setNotificationFlag(JMessageClient.FLAG_NOTIFY_WITH_SOUND);
    }

    /**
     * @Description: 初始化崩溃信息抓取配置
     * @author  liaoyong
     * */
    private void initCrashConfig(Context context) {
        CrashHandler crashHandler = CrashHandler.getInstance();
        crashHandler.init(context, this);
    }
}
